package com.cloudxingkong.dianyinke.Student.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;


import com.cloudxingkong.dianyinke.R;

import java.util.HashMap;
import java.util.List;

/**
 * Created by 云星空科技 on 2016/3/22.
 */
public class TPGVAdapter extends BaseAdapter {
    private Context context;
    private List<HashMap<String,Object>> imageList;

    public TPGVAdapter(Context context, List<HashMap<String, Object>> imageList) {
        this.context = context;
        this.imageList = imageList;
    }

    @Override
    public int getCount() {
        return imageList==null?0:imageList.size();
    }

    @Override
    public Object getItem(int position) {
        return imageList==null?0:imageList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
            convertView=View.inflate(context, R.layout.item_gridviewforteacherdongtai,null);
            holder=new ViewHolder();
            holder.imageView= (ImageView) convertView.findViewById(R.id.item_dongtai_iv);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        for (int i = 0; i < imageList.size(); i++) {
            Integer images = (Integer) imageList.get(i).get("images");
            holder.imageView.setImageResource(images);
        }
        return convertView;
    }
    private class ViewHolder{
        ImageView imageView;
    }
}
